package com.ocom.webapi.controller;

import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.request.human.FaceFeatureRequest;
import com.ocom.common.request.human.GetPerFeatureRequest;
import com.ocom.common.resp.Result;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.CompanyClientService;
import com.ocom.webapi.feign.HumanClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class PersonnelFeatureController {

    @Autowired
    private HumanClientService humanClientService;
    @Autowired
    private CompanyClientService companyClientService;


    @PostMapping(WebApiServiceUrl.URL_PerFeaturePageOnShow)
    public Result onShow(@RequestBody GetPerFeatureRequest request) {

        return humanClientService.personnelGetPerFeature(request);
    }

    @PostMapping(WebApiServiceUrl.URL_PerFeaturePageReset)
    public Result reset(@RequestBody GetPerFeatureRequest request) {

        return humanClientService.personnelReset(request);
    }

    @PostMapping(WebApiServiceUrl.URL_PerFeaturePageFeatureVersion)
    public Result featureVersion(@RequestBody GetPerFeatureRequest request) {
        return companyClientService.getFeatureVersion(request.getComId());
    }


    @PostMapping(WebApiServiceUrl.URL_PerFaceFeaturePageOnShow)
    public Result featureFaceList(@RequestBody FaceFeatureRequest request) {
        request.setComId(SecurityUtils.getYoCiUser().getComId());
        return humanClientService.featureList(request);
    }
}
